package com.raindrop.rd.parser.token;

import com.raindrop.rd.parser.Span;

/**
 * 讲源码转化成单个token，方便{@link TokenStream}处理
 *
 * @author BillDowney
 * @date 2021/3/22 22:44
 */
public class Token {

    /**
     * token类型
     */
    private final TokenType type;
    /**
     * 行信息
     */
    private final Span span;

    public Token(TokenType type, Span span) {
        this.type = type;
        this.span = span;
    }

    public TokenType getType() {
        return type;
    }

    public Span getSpan() {
        return span;
    }

    public String getText() {
        return span.getText();
    }

    @Override
    public String toString() {
        return "Token [type=" + type + ", span=" + span + "]";
    }
}
